import { Injectable, Logger } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { ConfigService } from '@nestjs/config';
import { BaseService } from '@wwjCommon/base/base.service';
import { CacheService } from '@wwjCommon/cache/cache.service';
import { LoggingService } from '@wwjCommon/logging/logging.service';
import { UploadService } from '@wwjVendor/upload/upload.service';
import { PayService } from '@wwjVendor/pay/pay.service';
import { SmsService } from '@wwjVendor/sms/sms.service';
import { NoticeService } from '@wwjVendor/notice/notice.service';

@Injectable()
export class CoreDependService extends BaseService<any> {
  private readonly logger = new Logger(CoreDependService.name);

  constructor(
    @InjectRepository(Object)
    protected readonly repository: Repository<any>,
    private readonly cacheService: CacheService,
    private readonly configService: ConfigService,
    private readonly loggingService: LoggingService,
    private readonly uploadService: UploadService,
    private readonly payService: PayService,
    private readonly smsService: SmsService,
    private readonly noticeService: NoticeService,
  ) {
    super(repository);
  }

  /**
   * installDepend
   * 对应 PHP: CoreDependService_core::installDepend()
   * 逻辑类型: undefined - undefined
   */
  async installDepend(addon: any) {
    // 基于PHP真实逻辑: installDepend
    // PHP原文: //composer文件扩展         $composer_content = $this->getComposerContent();         $addon_composer_content = $this->getAddonComposerContent($addon);     ...
//composer文件扩展
        const composer_content = this.getComposerContent(];
        const addon_composer_content = this.getAddonComposerContent(addon);
        if (typeof addon_composer_content.require)) {
            composer_content.require = Object.assign(composer_content.require, addon_composer_content.require);
  }

  /**
   * getComposerContent
   * 对应 PHP: CoreDependService_core::getComposerContent()
   * 逻辑类型: undefined - undefined
   */
  async getComposerContent() {
    // 基于PHP真实逻辑: getComposerContent
    // PHP原文: return $this->jsonFileToArray($this->server_composer_file);     }      /**      * 获取插件的composer内容      * @param string $addon      * @return array|mix...
return this.jsonFileToArray(this.server_composer_file);
    }

    /**
     * 获取插件的composer内容
     * @param string addon
     * @return array|mixed
     */
    async getAddonComposerContent(string addon)
    {
        const composer_path = this.geAddonPackagePath(addon)  + 'composer.json';
        return this.jsonFileToArray(composer_path);
    }

    /**
     * 更新composer内容
     * @param content
     * @return bool
     */
    async setComposerContent(content)
    {
        return this.writeArrayToJsonFile(content, this.server_composer_file);
    }

    /**
     * 获取npm文件内容
     * @param type //端口类型：admin  wap web
     */
    async getNpmContent(string type)
    {
        if (type == 'admin') {
            const file_path = this.admin_npm_file;
  }

  /**
   * getAddonComposerContent
   * 对应 PHP: CoreDependService_core::getAddonComposerContent()
   * 逻辑类型: undefined - undefined
   */
  async getAddonComposerContent(addon: string) {
    // 基于PHP真实逻辑: getAddonComposerContent
    // PHP原文: $composer_path = $this->geAddonPackagePath($addon) . 'composer.json';         return $this->jsonFileToArray($composer_path);     }      /**      * 更新c...
const composer_path = this.geAddonPackagePath(addon)  + 'composer.json';
        return this.jsonFileToArray(composer_path);
    }

    /**
     * 更新composer内容
     * @param content
     * @return bool
     */
    async setComposerContent(content)
    {
        return this.writeArrayToJsonFile(content, this.server_composer_file);
    }

    /**
     * 获取npm文件内容
     * @param type //端口类型：admin  wap web
     */
    async getNpmContent(string type)
    {
        if (type == 'admin') {
            const file_path = this.admin_npm_file;
  }

  /**
   * setComposerContent
   * 对应 PHP: CoreDependService_core::setComposerContent()
   * 逻辑类型: undefined - undefined
   */
  async setComposerContent(content: any[]) {
    // 基于PHP真实逻辑: setComposerContent
    // PHP原文: return $this->writeArrayToJsonFile($content, $this->server_composer_file);     }      /**      * 获取npm文件内容      * @param $type //端口类型：admin  wap web  ...
return this.writeArrayToJsonFile(content, this.server_composer_file);
    }

    /**
     * 获取npm文件内容
     * @param type //端口类型：admin  wap web
     */
    async getNpmContent(string type)
    {
        if (type == 'admin') {
            const file_path = this.admin_npm_file;
  }

  /**
   * getNpmContent
   * 对应 PHP: CoreDependService_core::getNpmContent()
   * 逻辑类型: undefined - undefined
   */
  async getNpmContent(type: string) {
    // 基于PHP真实逻辑: getNpmContent
    // PHP原文: if ($type == 'admin') {             $file_path = $this->admin_npm_file;...
if (type == 'admin') {
            const file_path = this.admin_npm_file;
  }

  /**
   * getAddonNpmContent
   * 对应 PHP: CoreDependService_core::getAddonNpmContent()
   * 逻辑类型: undefined - undefined
   */
  async getAddonNpmContent(addon: string, type: string) {
    // 基于PHP真实逻辑: getAddonNpmContent
    // PHP原文: if ($type == 'admin') {             $file_path = $this->geAddonPackagePath($addon) . 'admin-package.json';...
if (type == 'admin') {
            const file_path = this.geAddonPackagePath(addon)  + 'admin-package.json';
  }

  /**
   * setNpmContent
   * 对应 PHP: CoreDependService_core::setNpmContent()
   * 逻辑类型: undefined - undefined
   */
  async setNpmContent(content: any[], type: any[]) {
    // 基于PHP真实逻辑: setNpmContent
    // PHP原文: if ($type == 'admin') {             $file_path = $this->admin_npm_file;...
if (type == 'admin') {
            const file_path = this.admin_npm_file;
  }
}
